import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '昵称',
    align: 'center',
    dataIndex: 'nickname',
  },
  {
    title: '邮箱',
    align: 'center',
    dataIndex: 'email',
  },
  {
    title: '留言内容',
    align: 'center',
    dataIndex: 'content',
  },
  {
    title: '留言状态',
    align: 'center',
    dataIndex: 'status_dictText',
  },
  {
    title: '回复数量',
    align: 'center',
    dataIndex: 'replyCount',
  },
  {
    title: '点赞数量',
    align: 'center',
    dataIndex: 'likeCount',
  },
  {
    title: '创建时间',
    align: 'center',
    dataIndex: 'createTime',
  },
  {
    title: 'IP地址',
    align: 'center',
    dataIndex: 'ipAddress',
  },
  {
    title: '用户代理',
    align: 'center',
    dataIndex: 'userAgent',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '昵称',
    field: 'nickname',
    component: 'JInput',
    colProps: { span: 4 },
  },
  {
    label: '邮箱',
    field: 'email',
    component: 'JInput',
    colProps: { span: 4 },
  },
  {
    label: '留言内容',
    field: 'content',
    component: 'JInput',
    colProps: { span: 4 },
  },
  {
    field: 'status',
    label: '留言状态',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'message_status',
      stringToNumber: true,
    },
    colProps: { span: 4 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '昵称',
    field: 'nickname',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入昵称!' }];
    },
  },
  {
    label: '邮箱',
    field: 'email',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入邮箱!' }];
    },
  },
  {
    label: '留言内容',
    field: 'content',
    component: 'InputTextArea',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入留言内容!' }];
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  parentId: { title: '父留言ID(0表示顶级留言)', order: 0, view: 'number', type: 'number' },
  nickname: { title: '昵称', order: 1, view: 'text', type: 'string' },
  email: { title: '邮箱', order: 2, view: 'text', type: 'string' },
  content: { title: '留言内容', order: 3, view: 'textarea', type: 'string' },
  ipAddress: { title: 'IP地址', order: 4, view: 'text', type: 'string' },
  userAgent: { title: '用户代理', order: 5, view: 'text', type: 'string' },
  status: { title: '状态(0:待审核,1:已发布,2:已拒绝)', order: 6, view: 'number', type: 'number' },
  isAdminReply: { title: '是否管理员回复(0:否,1:是)', order: 7, view: 'number', type: 'number' },
  replyCount: { title: '回复数量', order: 8, view: 'number', type: 'number' },
  likeCount: { title: '点赞数量', order: 9, view: 'number', type: 'number' },
  createdTime: { title: '创建时间', order: 10, view: 'datetime', type: 'string' },
  updatedTime: { title: '更新时间', order: 11, view: 'datetime', type: 'string' },
  deleted: { title: '是否删除(0:否,1:是)', order: 12, view: 'number', type: 'number' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
